06. Defining Expectations
Defining Expectations
I've identified a number of expectations with this function, but it's now time to clearly define them (i.e., actually see them written out). Select all of the expectations you believe would apply to the add()
function below:
function add(x, y) {
return x + y;
}
SOLUTION:
- Expect 2 + 3 = 5
- Expect error if non-numbers are used
- Expect 0.1 + 0.2 = 0.3
Solution
Defining Expectations Solution - JavaScript Testing
INSTRUCTOR NOTE:
StackOverflow: Is JavaScript's Floating Point Math Broken?